<?php
namespace App\Traits;

use Tymon\JWTAuth\Facades\JWTAuth;

trait JwtClaims
{
    private $jwtClaims;

    public function getClaim($key)
    {
        if (!$this->jwtClaims) {
            $this->jwtClaims = JWTAuth::payload()->getClaims();
        }
        return $this->jwtClaims[$key]->getValue();
    }

    public function memberId()
    {
        return $this->getClaim('sub');
    }

    public function companyId()
    {
        return $this->getClaim('cid');
    }

}